<template>
  <div>
    <el-form ref="pram" :model="pram" :rules="rules" label-width="100px" @submit.native.prevent>
      <el-form-item label="销假情况" prop="cancellation">
        <el-select v-model="pram.cancellation" placeholder="销假情况" clearable style="width: 100%">
          <el-option
            v-for="(item,index) in typeList"
            :key="index"
            :label="item.name"
            :value="item.cancellation"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="备注" prop="remark">
        <el-input v-model="pram.remark" type="textarea" :rows="7" placeholder="备注"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="handlerSave()"> 确定</el-button>
        <el-button @click="close">取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { cancellationOfLeave, getApplyDetail } from '@/api/dashboard'

export default {
  components: {},
  props: {
    id: {
      type: Number,
      default: null
    }
  },
  data() {
    return {
      pram: {
        cancellation: null,
        remark: null,
        id: 0
      },
      rules: {
        cancellation: [{ required: true, message: '请选择销假情况', trigger: ['blur', 'change'] }]
      },
      typeList: [{ cancellation: 1, name: '未销假' }, { cancellation: 2, name: '已销假' }]
    }
  },
  mounted() {
    this.getApplyDetail()
  },
  methods: {
    close() {
      this.$emit('hideDialog1')
    },
    handlerSave() {
      this.pram.id = this.id
      const _pram = this.pram
      console.log(_pram)
      cancellationOfLeave(_pram).then(data => {
        this.$message.success('修改成功')
        this.$emit('hideDialog1')
      })
    },
    getApplyDetail() {
      getApplyDetail(this.id).then(data => {
        this.pram = data
      })
    }
  }
}
</script>

<style scoped>

</style>
